package com.example.smartmedicalsystem.repository;

import com.example.smartmedicalsystem.entity.Medicine;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import java.util.List;

public interface MedicineRepository extends JpaRepository<Medicine, Long> {
    List<Medicine> findByNameContainingIgnoreCase(String keyword);
    List<Medicine> findByStockGreaterThan(int stock);

    @Query("SELECT m FROM Medicine m WHERE m.stock < :threshold")
    List<Medicine> findLowStockMedicines(@Param("threshold") int threshold);
}